package exception;

public class TryCatchDemo {
    public static void main(String[] args) {

        System.out.println("程序开始了");

        try {
//            String str = null;
//            System.out.println(str.length());

            String string = "";
            System.out.println(string.charAt(0));

            System.out.println("===========================");

        }catch (NullPointerException n){
            System.out.println("出现了空指针异常，并且已经解决了");
        }catch (StringIndexOutOfBoundsException e){
            System.out.println("出现字符串下标越界，并解决了");
        }
      /*  catch (NullPointerException | StringIndexOutOfBoundsException e){
            System.out.println("出现异常，并解决了");
        }*/

        //System.out.println(str.length());

        System.out.println("程序结束了");

    }
}
